package com.event.system.service.impl;

import com.event.common.core.text.Convert;
import com.event.system.domain.SysEventRegion;
import com.event.system.mapper.SysEventRegionMapper;
import com.event.system.service.ISysEventRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class SysEventRegionServiceImpl implements ISysEventRegionService {

    @Autowired
    private SysEventRegionMapper mapper;

    /**
     * 根据条件分页查询展会区域信息
     *
     * @param sysEventRegion
     * @return
     */
    @Override
    public List<SysEventRegion> selectSysEventRegionList(SysEventRegion sysEventRegion) {
        return mapper.selectSysEventRegionList(sysEventRegion);
    }

    /**
     * 根据id查找展会区域信息
     *
     * @param regionId
     * @return
     */
    @Override
    public SysEventRegion selectSysEventRegionByRosterId(Long regionId) {
        return mapper.selectSysEventRegionByRosterId(regionId);
    }

    /**
     * 新增展会区域信息
     *
     * @param sysEventRegion
     * @return
     */
    @Override
    public int add(SysEventRegion sysEventRegion) {
        sysEventRegion.setEventNum(sysEventRegion.getAreaNum() + sysEventRegion.getBoothNum());
        sysEventRegion.setRegionStatus(3);
        return mapper.add(sysEventRegion);
    }

    /**
     * 修改展会区域信息
     *
     * @param sysEventRegion
     * @return
     */
    @Override
    public int update(SysEventRegion sysEventRegion) {
        sysEventRegion.setEventNum(sysEventRegion.getAreaNum() + sysEventRegion.getBoothNum());
        return mapper.update(sysEventRegion);
    }

    /**
     * 删除展会区域信息
     *
     * @param regionId
     * @return
     */
    @Override
    public int deleteSysEventRegionByRegionId(String regionId) {
        Long[] ids = Convert.toLongArray(regionId);
        return mapper.deleteSysEventRegionByRegionId(ids);
    }

    /**
     * 根据regionId修改区域状态为审核中
     *
     * @param regionId
     * @return
     */
    @Override
    public int updateByRegionIdToOne(Long regionId) {
        return mapper.updateByRegionIdToOne(regionId);
    }

    /**
     * 根据regionId修改区域状态为已定
     *
     * @param regionId
     * @return
     */
    @Override
    public int updateByRegionIdToTwo(Long regionId) {
        return mapper.updateByRegionIdToTwo(regionId);
    }

    /**
     * 根据regionId修改区域状态为未定
     *
     * @param regionId
     * @return
     */
    @Override
    public int updateByRegionIdToThree(Long regionId) {
        return mapper.updateByRegionIdToThree(regionId);
    }
}
